import { Mt } from '@/api/manager/mt'
import requestMeeting, { request } from '@/plugins/axios'
import { IntelligenceStatusItem, deviceItem, powerItem } from './interface'

/** 获取会议纪要/签到状态 */
export const fetchGetIntelligenceStatus = async (meetingMoid: string) =>
	requestMeeting<IntelligenceStatusItem>({
		url: `/mcc/${meetingMoid}/kis/intelligence_status`,
		method: 'get',
	}).then((res) => (res.success && res.data ? res.data : undefined))

/** 获取可远程开机的终端 */
export const fetchGetListDevices = async (meetingMoid: string) =>
	requestMeeting<deviceItem[]>({
		url: `/mcc/${meetingMoid}/kis/devices`,
		method: 'get',
	}).then((res) => (res.success ? res.data : undefined))

/** 一键开机 */
export const fetchPowerOnAll = async (meetingMoid: string) =>
	requestMeeting<powerItem[]>({
		url: `/mcc/${meetingMoid}/kis/power_on/all`,
		method: 'get',
	}).then((res) => (res.success ? res.data : undefined))

/** 单个开机 */
export const fetchPowerOnOne = async (mt: Mt, meetingMoid: string, isSuperMeeting: boolean) =>
	requestMeeting<powerItem>({
		url: `/mcc/${meetingMoid}/kis/power_on`,
		method: 'post',
		data: {
			mt_id: mt.mtKey,
			interactive_mt: !isSuperMeeting ? 1 : mt.status.isInteractive ? 1 : 0,
		},
	}).then((res) => (res.success ? res.data : { operation: 0 }))

/** 开启会议纪要 */
export const fetchRecord = async (operation: 0 | 1, meetingMoid: string) =>
	request({
		url: `/mcc/${meetingMoid}/kis/record`,
		method: 'post',
		data: JSON.stringify({ operation: operation }),
	}).then((res) => res)

/** 开启会议签到 */
export const fetchSign = async (operation: 0 | 1, meetingMoid: string) =>
	request({
		url: `/mcc/${meetingMoid}/kis/sign`,
		method: 'post',
		data: JSON.stringify({ operation: operation }),
	}).then((res) => res)

/** 开启同声字幕 */
export const fetchSubtitle = async (operation: 0 | 1, meetingMoid: string) =>
	request({
		url: `/mcc/${meetingMoid}/kis/subtitle`,
		method: 'post',
		data: JSON.stringify({ operation: operation }),
	}).then((res) => res)
